package com.lostad.app.core.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import com.lostad.app.core.domain.AppUser;

public interface UserDao extends CrudRepository<AppUser,String> {

	/**
	 * 使用query 注解进行update 或者 delete 语句时，需要添加 modifying 注解修饰
	 * nativeQuery 是否为原生sql
	 */
	@Query(nativeQuery = true,value = "delete from app_user where id=?")
	@Modifying
	public void deleteAllBySql(String userId);
   
	/**
	 * 查询，非事物操作
	 * @return
	 */
	@Query(nativeQuery = true, value = " select username,nickname from app_user ")
	@Transactional(readOnly = true)
	List<AppUser> findUserBySql();
}
